<template>
  <div
    class="cards-content cars-position-usually"
    :class="props.position === 'LEFT' ? 'cards-left' : 'cards-right'"
  >
    <div class="cards-bgc-usually"></div>
    <div class="model-box-top g-flex-between-start">
      <div class="box-top-left g-flex">
        <div class="box-top-image">
          <img :src="modelDetail?.fileUrl || productUrl" />
        </div>
        <div class="box-top-title g-mt1">
          <div class="top-title-code-text"> 编码：{{ empty(modelDetail?.modelCode) }} </div>
          <div class="top-title-name-text" v-ellTooltip> {{ empty(modelDetail?.modelName) }} </div>
        </div>
      </div>
      <el-button class="box-top-btn" text type="primary" @click="changeModel">更换模型</el-button>
    </div>
    <div class="model-box-bottom g-flex-start-center">
      <div class="usually-font"> 核算年份：{{ empty(modelDetail?.accountYear) }}年 </div>
      <div class="vertical-rows"></div>
      <div class="usually-font">
        核算标准：{{ modelDetail?.standard ? StandardMap[modelDetail.standard] : '-' }}
      </div>
      <div class="vertical-rows"></div>
      <div class="usually-font"> 核算时间：{{ empty(modelDetail?.calcTime) }} </div>
    </div>
  </div>
</template>

<script lang="ts" setup name="SelectedModelBox">
import { withDefaults, defineProps, defineEmits } from 'vue';
import type { ModelPositionType } from '../../../../types';
import { empty } from '@/utils';
import { StandardMap } from '@/constants/pcf';
import type { GetVisibleModelDetailResult } from '@/apis/pcf/pcfForm/model/pcfFormModel';
import productUrl from '@/assets/images/icon_product.png';

interface SelectedModelBoxProps {
  position: ModelPositionType;
  modelDetail: GetVisibleModelDetailResult;
}

const props = withDefaults(defineProps<SelectedModelBoxProps>(), {});
const emits = defineEmits(['change']);

function changeModel() {
  emits('change');
}
</script>

<style lang="scss" scoped>
.cards-content {
  flex-shrink: 0;
  width: calc(50% - 8px);
  padding: 0 16px;
  &.cars-position-usually {
    position: relative;
    border-radius: 6px;
    .cards-bgc-usually {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 32px;
    }
  }
  &.cards-left {
    border-top: 2px solid #03ac82;
    background: #fff;
    .cards-bgc-usually {
      background: linear-gradient(180deg, #f3fffc 0%, rgba(243, 255, 252, 0.2) 100%);
    }
  }
  &.cards-right {
    border-top: 2px solid#4C91F1;
    background: #fff;
    .cards-bgc-usually {
      background: linear-gradient(180deg, #eef6ff 0%, rgba(238, 246, 255, 0.2) 100%);
    }
  }
  .model-box-top {
    position: relative;
    z-index: 1;
    padding: 16px 0 14px;
    width: 100%;
    height: 80px;
    border-bottom: 1px solid rgba(235, 239, 242, 1);
    .box-top-left {
      width: calc(100% - 80px);
      .top-title-code-text {
        z-index: 99;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #435970;
        line-height: 20px;
      }
      .top-title-name-text {
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #0a1f33;
        line-height: 26px;
      }
    }
    .box-top-image {
      margin-right: 10px;
      width: 63px;
      height: 48px;
      background: #ffffff;
      border-radius: 3px;
      border: 1px solid #f0f4f7;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .box-top-title {
      width: calc(100% - 74px);
    }
  }
  .model-box-bottom {
    width: 100%;
    height: 46px;
    .vertical-rows {
      width: 1px;
      height: 12px;
      line-height: 18px;
      margin: 0 8px;
      background: #ebeff2;
      align-self: center;
    }

    .usually-font {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #435970;
      line-height: 22px;
    }
  }
}
</style>
